package com.demo.factory;

import org.springframework.cloud.openfeign.FeignClientBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @author KingYan
 * @date 2024/7/19
 * @apiNote
 */
@Component
public class DynamicFeignClientFactory<T> {

	private FeignClientBuilder feignClientBuilder;

	public DynamicFeignClientFactory(ApplicationContext appContext) {
		this.feignClientBuilder = new FeignClientBuilder(appContext);
	}

	public T getFeignClient(final Class<T> type, String serviceId) {
		return this.feignClientBuilder.forType(type, serviceId).build();
	}
}
